


import {
  get,
  post,
  put,
} from "./base_service"


/**
 * 佳宝我的相关接口
 *
 * allen  2023-12-19
 */

/**
 * 
 * 获取个人信息
 */
const queryUserInfo = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/user").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 
 * 绑定支付宝信息
 */
const bindAiPayInfo = () => {
  return new Promise((resolve, reject) => {
    post("/api/front/user").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
 * 
 * 更新支付宝信息
 * data:{
 *   aliRealName,
 *   aliAccount,
 *   smsCode,
 * }
 */
const updateAiPayInfo = (data) => {
  return new Promise((resolve, reject) => {
    put("/api/front/updateAli", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 
 * 获取个人展示模块
 */
const queryUserMenus = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/menu/user").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}


/**
 * 
 * 绑定手机号
 */
const bindingPhone = (data) => {
  return new Promise((resolve, reject) => {
    post("/api/front/wechat/register/binding/phone", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}



/**
 * 编辑个人信息
 * data:{
 *   nickname:''
     phone:''，
     avatar:''
* }
 */
const editUserInfo = (data) => {
  return new Promise((resolve, reject) => {
    post("/api/front/user/edit", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
// 随机获取企业微信客服二维码
const randomServiceCode = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/customer/service/random").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
// 随机获取财务微信客服二维码
const randomWalletCode = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/customer/service/withdraw/random").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}








module.exports = {
  queryUserInfo,
  queryUserMenus,
  bindingPhone,
  editUserInfo,
  bindAiPayInfo,
  updateAiPayInfo,
  randomServiceCode,
  randomWalletCode,
}

